package com.jiangchuang.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jiangchuang.domain.entity.Dish;
import com.jiangchuang.domain.response.GetDishByIdRes;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface DishMapper extends BaseMapper<Dish> {

    @Select("select d.id,d.name,d.cover,d.mark,d.num,d.price,t.id as type_id,t.name as type,d.uid, u.nickname as username, u.portrait_url, d.create_time " +
            "from dish d left join user u on u.id=d.uid left join dish_type t on t.id=d.type_id where d.id = #{id}")
    GetDishByIdRes getDishById(Integer id);

    // 从idx位置开始获取num条数据
    @Select("select id,cover from dish limit #{idx}, #{num}")
    List<Dish> getLimitDish(int idx, int num);
}
